package cn.kgc.rbac.utils;

import java.util.Random;

/**
 * @author: mosin
 * @version: v1.0  2023/1/31
 * 随机盐工具类
 */
public class SaltUtil {

    public static  String getSalt(Integer length){

        String str = "1234567890!@#$%^&*qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM";
        char[] chars = str.toCharArray();
        Random random = new Random();

        StringBuilder stringBuilder = new StringBuilder();
        // 获取用户指定长度的salt
        for (int i = 0; i < length; i++) {
            stringBuilder.append(chars[random.nextInt(chars.length)]);
        }
        return stringBuilder.toString();
    }

}
